﻿using System;

namespace KPIS.GERP.GHRMS.MODEL
{
    // hrm_mp_position_work_on_duty
    public class WorkOnDuty
    {
        public int wod_seq { get; set; }
        public string ref_no { get; set; }
        public int to_pos_seq { get; set; }
        public int by_emp_seq { get; set; }
        public string to_emp_name { get; set; }
        public string by_emp_name { get; set; }
        public DateTime start_date { get; set; }
        public DateTime end_date { get; set; }
        public bool see_old_message { get; set; }
        public string description { get; set; }
        public string record_status { get; set; }
        public int created_by { get; set; }
        public DateTime created_when { get; set; }
        public int? updated_by { get; set; }
        public DateTime? updated_when { get; set; }
        public bool IsActive{get { return record_status == "A" && DateTime.Now <= end_date && DateTime.Now >= start_date; }}
        public bool IsPass{get { return DateTime.Now > end_date; }}
        public bool IsNotYet{get { return DateTime.Now < start_date; }}
        public bool IsInTimeRange{get { return DateTime.Now <= end_date && DateTime.Now >= start_date; }}
        public bool IsApproved{get { return record_status == "A"; }}

        public string EffectiveWord
        {
            get
            {
                if (IsPass) return "ผ่านไปแล้ว";
                if (IsActive) return "มีผลใช้อยู่";
                if (IsNotYet && IsApproved) return "ยังไม่ถึงช่วงเวลา (อนุมัติแล้ว)";
                if (IsNotYet && !IsApproved) return "ยังไม่ถึงช่วงเวลา ยังไม่อนุมัติ";
                return "ไม่ทราบ";
            }
        }
    }
}
